#pragma once

#include <memory>
#include "rtda/heap/cp_memberref.h"

namespace jvm {
namespace heap {

class Method;

class MethodRef : public MemberRef {
private:
    std::shared_ptr<Method> m_pMethod;

public:
    MethodRef(std::shared_ptr<ConstantPool> pCp, const std::shared_ptr<classfile::ConstantMethodRefInfo> pMemberrefInfo);
    static std::shared_ptr<MethodRef> newMethodRef(std::shared_ptr<ConstantPool> pCp, const std::shared_ptr<classfile::ConstantMethodRefInfo> pMethodrefInfo);
    
    std::shared_ptr<Method> resolvedMethod();
    void resolveMethodRef();

private:
    static std::shared_ptr<Method> lookupMethod(std::shared_ptr<Class> pClass, const std::string& name, const std::string& descriptor);

};

} // namespace heap
} // namespace jvm

